#include "Pcm2AacWindow.h"
#include "Pcm2AacThread.h"
#include <QMessageBox>
#include <QFileDialog>

Pcm2AacWindow::Pcm2AacWindow(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	this->setWindowTitle("PCM 转 AAC");
}

void Pcm2AacWindow::inputPcmPath()
{
	QString filter = "Wav(pcm) 文件 (*.*);;所有文件 (*.*)";
	QString filePath = QFileDialog::getOpenFileName(this, "选择要转换的文件", "E:\\BaiduNetdiskDownload\\test_resource", filter);
	ui.inputPcmEdit->setText(filePath);
}
void Pcm2AacWindow::outputAacPath()
{
	QString directoryPath = QFileDialog::getSaveFileName(nullptr, "选择输出文件路径", "E:\\BaiduNetdiskDownload\\test_resource", "媒体文件(*.*)");
	ui.outputAACEdit->setText(directoryPath);
}
void Pcm2AacWindow::startChange() {
	QString inPath = ui.inputPcmEdit->text();
	QString outPath = ui.outputAACEdit->text();
	if (inPath.isEmpty() || outPath.isEmpty()) {
		QMessageBox::warning(this, "温馨提示", "输入、输出文件的路径不能为空");
		return;
	}
	Pcm2AacThread::Get()->inFile = inPath;
	Pcm2AacThread::Get()->outFile = outPath;
	Pcm2AacThread::Get()->Start();
}

Pcm2AacWindow::~Pcm2AacWindow()
{
}
